// pages/CookDetail/CookDetail.js
const app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    menu_id:'',
    author:'',
    attented:false,
    col:false,
    attention_list:[],//用户关注的
    collection_list:[],
    food:{},
    userInfo: {},
    hasUserInfo: false,
    mycomment:'',//评论框值
    canIUse: wx.canIUse('button.open-type.getUserInfo')
  },
  
  showfoodshare(){

  },
  showcomment(){

  },
  showattented(){

  },
  //失去焦点获取值
  getshareword:function(e){
    this.setData({
      share_content: e.detail.value
    })
  },
  //提交分享
  
 
  //选择图片分享
  takeshare:function(){
    let that = this;
    wx.showActionSheet({
      itemList: ['从相册选择', '拍照'],
      itemColor: '#ef8383',
      success: function (res) {
        var choseType = res.tapIndex == 0 ? "album" : res.tapIndex == 1 ? "camera" : "";
        if (choseType != "") {
          wx.chooseImage({
            sizeType: ['compressed'],//压缩图
            sourceType: [choseType],
            count: 1,//每次添加一张
            success: function (res) {
              that.setData({
                showModalStatus1: true,
                tempFilePaths: res.tempFilePaths[0]
              })

            }
          })
        }
      },
      fail(res) {
        //console.log(res.errMsg)
      }
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
    setTimeout(function () {
      wx.hideLoading()
    }, 1000)
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    this.showfoodshare();
    this.showcomment();
    this.showattented();
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  },

  //写评论弹窗
  writecomment: function () {
    // 显示遮罩层
    var animation = wx.createAnimation({
      duration: 400,
      timingFunction: "linear",
      delay: 0
    })
    this.animation = animation
    animation.translateY(300).step()
    this.setData({
      animationData: animation.export(),
      showModalStatus: true
    })
    setTimeout(function () {
      animation.translateY(0).step()
      this.setData({
        animationData: animation.export()
      })
    }.bind(this), 200)
  },
  // 隐藏遮罩层
  hideView() {
    var animation = wx.createAnimation({
      duration: 200,
      timingFunction: "linear",
      delay: 0
    })
    this.animation = animation
    animation.translateY(300).step()
    this.setData({
      animationData: animation.export(),
    })
    setTimeout(function () {
      animation.translateY(0).step()
      this.setData({
        animationData: animation.export(),
        showModalStatus: false
      })
    }.bind(this), 200)
  },

  
  

  //评论输入框失去焦点保存
  savecomment: function (e) {
    let that = this;
    that.setData({
      mycomment: e.detail.value
    })
    //console.log(that.data.mycomment);
  },
  //发表评论
 


})